package com.etheart.model.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.search.annotations.AnalyzerDef;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.DateBridge;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Resolution;
import org.hibernate.search.annotations.Similarity;
import org.hibernate.search.annotations.Store;
import org.hibernate.search.annotations.TokenizerDef;
import org.wltea.analyzer.lucene.IKSimilarity;
import org.wltea.analyzer.solr.IKTokenizerFactory;

/**
 * Album entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "_album", catalog = "etheart")
@Indexed
@AnalyzerDef(name = "customanalyzer_album",
		tokenizer = @TokenizerDef(factory = IKTokenizerFactory.class))
@Similarity(impl=IKSimilarity.class)
public class Album implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = -3682153567690793393L;
	@DocumentId
	@Field(index = Index.UN_TOKENIZED, store = Store.NO)
	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	private Long id;
	
	@Column(name = "net_id", length = 30)
	private String netId;
	
	@IndexedEmbedded(prefix="singer.",depth=1)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "singerid")
	private Singer singer;
	
	@Field(index = Index.TOKENIZED, store = Store.NO)
	@Column(name = "albumname", length = 255)
	private String albumname;
	
	@Field(index = Index.UN_TOKENIZED, store = Store.NO)
	@DateBridge(resolution = Resolution.DAY)
	@Column(name = "publishtime", length = 19)
	private Date publishtime;
	
	@Column
	private Integer salenum;
	
	@Field(index = Index.TOKENIZED, store = Store.NO)
	@Column
	private String coname;
	
	@Field(index = Index.UN_TOKENIZED, store = Store.NO)
	@DateBridge(resolution = Resolution.DAY)
	@Column(name = "add_time", length = 19)
	private Date addTime;
	
	@Field(index = Index.TOKENIZED, store = Store.NO)
	@Column
	private String intro;
	
	@Column(name = "picture")
	private String picture;
	
	@Field(index = Index.UN_TOKENIZED, store = Store.NO)
	@Column(name = "_language", length = 20)
	private String language;
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "album")
	@ContainedIn
	private Set<Song> songs = new HashSet<Song>(0);

	// Constructors

	/** default constructor */
	public Album() {
	}



	// Property accessors
	
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	
	public String getNetId() {
		return netId;
	}

	public void setNetId(String netId) {
		this.netId = netId;
	}

	
	public Singer getSinger() {
		return this.singer;
	}

	public void setSinger(Singer singer) {
		this.singer = singer;
	}


	
	public Date getPublishtime() {
		return this.publishtime;
	}

	public void setPublishtime(Date publishtime) {
		this.publishtime = publishtime;
	}


	public Integer getSalenum() {
		return this.salenum;
	}

	public void setSalenum(Integer salenum) {
		this.salenum = salenum;
	}


	public String getConame() {
		return this.coname;
	}




	public void setConame(String coname) {
		this.coname = coname;
	}


	public Date getAddTime() {
		return this.addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}


	public String getIntro() {
		return this.intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}




	
	public String getAlbumname() {
		return albumname;
	}



	public void setAlbumname(String albumname) {
		this.albumname = albumname;
	}



	public String getPicture() {
		return picture;
	}



	public void setPicture(String picture) {
		this.picture = picture;
	}



	public Set<Song> getSongs() {
		return this.songs;
	}

	public void setSongs(Set<Song> songs) {
		this.songs = songs;
	}

}